package com.shu.timerTask;


import com.google.common.base.Stopwatch;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;

import java.util.concurrent.*;

/**
 * @author ssm
 * @version V1.0
 * @description:
 * @date 2019/4/8 11:01
 */

public class Base {
    public CountDownLatch downLatch1 = new CountDownLatch(1);
    public CountDownLatch downLatch5 = new CountDownLatch(5);
    public CountDownLatch downLatch10 = new CountDownLatch(10);
    public CountDownLatch downLatch100 = new CountDownLatch(100);

    public CyclicBarrier cyclicBarrier1 = new CyclicBarrier(1);
    public CyclicBarrier cyclicBarrier5 = new CyclicBarrier(5);
    public CyclicBarrier cyclicBarrier10 = new CyclicBarrier(10);
    public CyclicBarrier cyclicBarrier100 = new CyclicBarrier(100);

    public Semaphore semaphore1 = new Semaphore(1);
    public Semaphore semaphore5 = new Semaphore(5);
    public Semaphore semaphore10 = new Semaphore(10);
    public Semaphore semaphore100 = new Semaphore(100);

    public final Stopwatch stopWatch = Stopwatch.createUnstarted();
    public ExecutorService cachedThreadPool = Executors.newCachedThreadPool();


    @BeforeEach
    void before() {
        stopWatch.reset().start();
    }

    @AfterEach
    void after() {
        System.out.println("执行完毕,耗时" + stopWatch.elapsed(TimeUnit.MILLISECONDS) + "毫秒");
    }
}
